package dyyx.intf;

import java.util.HashMap;
import java.util.Map;

import org.apache.kafka.clients.producer.RecordMetadata;

import dyyx.util.HostInfoUtil;
import dyyx.util.JmxUtil;
import dyyx.util.KafkaUtil;

public class AllInOneServiceImpl implements AllInOneService{
	
	public String echo(String str){
		return str+"@"+HostInfoUtil.getHostIp()+"_"+JmxUtil.getPid();
	}
	
	public 	Map<String,Object> send(int topicIndex,String key,String value)throws Exception{
		RecordMetadata meta = KafkaUtil.sendMsg(topicIndex, key, value);
		Map<String,Object> map = new HashMap<>();
		map.put("offset", meta.offset());
		map.put("timestamp", meta.timestamp());
		map.put("partition", meta.partition());
		map.put("topic", meta.topic());
		map.put("ip", HostInfoUtil.getHostIp());
		map.put("pid",JmxUtil.getPid());

		
		return map;
	}

	
}